package top.infopub.enums.fia;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*资金上交--上交类型*/
public enum HandTypeEnum {

    //上交类型，1=融资款，2=日常经营借款，3=项目回款，4=政府资本金，5=政府借款，6=政府补贴，7=指标收入，8=中央财政基金，9=回购额
    HAND_TYPE1("1", "融资款"),
    HAND_TYPE2("2", "日常经营借款"),
    HAND_TYPE3("3", "项目回款"),
    HAND_TYPE4("4", "政府资本金"),
    HAND_TYPE5("5", "政府借款"),
    HAND_TYPE6("6", "政府补贴"),
    HAND_TYPE7("7", "指标收入"),
    HAND_TYPE8("8", "中央财政基金"),
    HAND_TYPE9("9", "回购额");

    private String code;

    private String name;

    HandTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static HandTypeEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (HandTypeEnum ite : HandTypeEnum.values()) {
            if (StringUtils.equals(code, ite.getCode())) {
                return ite;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (HandTypeEnum ite : HandTypeEnum.values()) {
            map = new HashMap<>();
            map.put("code", ite.getCode());
            map.put("name", ite.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
